<template>
<div class="track_container flex" @click="gojinriredian">
      <div class="track">
        <div class="track_icon_box">
            <img :src="item.albumCoverPath" class="track_img">
            <img src="../../../assets/images/player_icon.png" class="music_icon">
        </div>
        <div class="track_text">
            {{ item.title }}
        </div>
        <div class="track_databoard">
            <div class="track_box1">
                <div class="track_text1">
                    <img src="../../../assets/images/user_icon.png" class="track_icon">
                    {{ item.anchorName }}
                </div>
            </div>
            <div class="track_box2">
                <div class="track_text2"><img src="../../../assets/images/music_icon.png" class="track_icon">{{ playCount }}</div>
            </div>
        </div>
      </div>
    </div>
</template>

<script setup lang="ts">
import type { AnyObject } from '@/types/newpeople';
import { computed } from 'vue';

const props = defineProps<{
    item:AnyObject
}>()


const formatNumber = (number:number) => {
  if (number >= 100000000) {
    return (number / 100000000).toFixed(2) + ' 亿';
  } else if (number >= 10000) {
    return (number / 10000).toFixed(2) + ' 万';
  } else {
    return number.toString();
  }
}
const playCount = computed(()=>{
  let playCount = formatNumber(props.item.playCount)
  return playCount
})

const gojinriredian = () => {
    window.location.href="https://m.ximalaya.com/sound/" + props.item.trackId
}
</script>

<style scoped lang="less">
.track_container{
  flex-direction: row;
  flex-wrap: nowrap;
  width: 345.2px;
  height: 100px;
}

.track_icon_box{
    width: 70px;
    height: 70px;
    float: left;
    background-color:#232326;
    opacity: 0.7;
    z-index: 99;
    border-radius: 10px;
}

.track{
    width: 260px;
    height: 70px;
}
.track_img{
    float: left;
    width: 70px;
    height: 70px;
    border-radius: 10px;
    position: absolute;
}

.music_icon{
    width: 13.69px;
    height: 15.95px;
    position: relative;
    left: 30px;
    top: 24px;
}

.track_text{
    width: 260px;
    height: 44.15px;
    font-size: 16px;
    color: #40404C;
    margin-left: 80px;
}
.track_databoard{
    width: 260px;
    height: 18.8px;
    margin-left: 80px;
}
.track_box1{
    // width: 80px;
    height: 18.4px;
    float: left;
}
.track_box2{
    width: 50px;
    height: 18.4px;
    float: left;
}
.track_icon{
    width: 12px;
    height: 12px;
    margin-right: 4px;
}
.track_text1{
    height: 18px;
    font-size: 12px;
    color: #999;
    margin-top: 6px;
}
.track_text2{
    display: flex;
    justify-content: center;
    align-items: center;
    width: 65px;
    height: 18px;
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    margin-left: 8px;
}
</style>